package com.fordmotor.api;

import com.alibaba.fastjson.JSONObject;
import com.fordmotor.constant.GaodeEnum;
import com.fordmotor.pojo.GaodeObject;
import com.fordmotor.service.LbsService;
import com.google.common.collect.Maps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
/**
 * @author THUNDEROBOT
 * @date 2020/07/07 12:15
 */
@RestController
@RequestMapping("/lbs")
public class LbsAPI {


    @Autowired
    private LbsService lbsService;

//    @GetMapping("/keyWordSearch")
//    public String keyWordSearch(Float longitude,Float latitude,String keyword){
//
//        return "";
//    }
//
//    @GetMapping("/aroundSearch")
//    public String aroundSearch(Float longitude,Float latitude,String keyword){
//
//        return "";
//    }

    /**
     * 查询某用户输入位置五公里范围的福特4S店
     * @param longitude
     * @param latitude
     * @param uid
     * @return
     */
    @PostMapping("/fordSearch")
    public Map<String,Object> ford(Double longitude,Double latitude,String uid){
        Map<String,Object> result = Maps.newHashMap();
        List<GaodeObject> list = lbsService.aroundSearch(longitude,latitude, GaodeEnum.FORD.getValue());
        result.put("uid",uid);
        result.put("list",list);
//        String returnResult = JSONObject.toJSONString(result);
        return result;
    }

    /**
     *查询某用户输入位置五公里范围的福特4S店
     * @param longitude
     * @param latitude
     * @param uid
     * @return
     */
    @PostMapping("/sinopecSearch")
    public Map<String,Object> sinopec(Double longitude, Double latitude,String uid){
        Map<String,Object> result = Maps.newHashMap();
        List<GaodeObject> list = lbsService.aroundSearch(longitude,latitude, GaodeEnum.SINOPEC.getValue());
        result.put("uid",uid);
        result.put("list",list);
        return result;
    }

}
